<?php
/***************************************************************************
*                                main.php
 *
 *   Begin date           	: 
 *   Copyright            	: 
 *   Email                	: 
 ***************************************************************************/
defined('PHP5_PHP') or die("Application is stopping!!!");
$smarty->setCompileDir(sprintf($php5RootTempalteCPath, ''));
$tpl = sprintf($php5TemplateFile, $language, 'testimonials', 'main.tpl');
if(!is_file($tpl )) {
	die("can not find template");
}

$sWhere = '';
$sWhere = ' AND n.publish = 1 ';	

//paging
$currPage = php5GetParam($_REQUEST, 'p', 1);
$limit = 1;
$php5DB->setQuery("SELECT COUNT(n.id)
				FROM #__testimonials AS n
				INNER JOIN #__category AS c ON n.category_id = c.id
				WHERE 1 ".$sWhere." 
				ORDER BY n.ordering ASC, n.id ASC");
$recordTotal = $php5DB->loadResult();

$startLimit= ($currPage - 1) * $limit;

$pageTotal = ceil($recordTotal / $limit);
$currPage = $currPage > $pageTotal ? $pageTotal : $currPage;
$paging = new php5Paging($pageTotal, $currPage);
$paging->url = sefBuild($php5WebPath, 'index.php?o=testimonials&m=main', 1).'?';
$smarty->assign('paging', $paging->showDivNewsPages());

// News list
$php5DB->setQuery("SELECT n.*, c.name
				FROM #__testimonials AS n
				INNER JOIN #__category AS c ON n.category_id = c.id
				WHERE 1 ".$sWhere." 
				ORDER BY n.ordering ASC, n.id ASC 
				LIMIT $startLimit, $limit");	
$rows= $php5DB->loadObjectList();
foreach ($rows as $row){
	$row->post_date = date("m.j.Y", $row->post_date);
}
$smarty->assign('rows', $rows);
$smarty->assign('main', $smarty->fetch($tpl));



